package com.itheima;

import com.itheima.utils.DownLoadUtil;
import com.itheima.utils.POIUtils;
import org.junit.Test;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class POIDownLoad {
    @Test
    public void test() throws Exception {
        String[] str  = {"姓名","年龄","性别","籍贯"};
        List<Person> list = new ArrayList<>();
        Person p1 = new Person("张三",16,"男","北京");
        Person p2 = new Person("李四",17,"男","北京");
        Person p3 = new Person("王五",18,"女","北京");
        Person p4 = new Person("赵柳",19,"男","北京");
        list.add(p1);
        list.add(p2);
        list.add(p3);
        list.add(p4);
        DownLoadUtil.writeExcel("测试",str,list);

    }
}
/*
for (int i = 0; i < checkItems.size(); i++) {
    XSSFRow row = sheet.createRow(i+1);
    Field[] fields = checkItems.get(i).getClass().getDeclaredFields();
    for (int j = 0; j < fields.length; j++) {
        Method declaredMethod = checkItems.get(i).getClass().getDeclaredMethod("get" + fields[j].getName().substring(0, 1).toUpperCase() + fields[j].getName().substring(1));
        Object invoke = declaredMethod.invoke(checkItems.get(i));
        if(invoke!=null){
            if(invoke instanceof String){
                row.createCell(j).setCellValue((String)invoke);
            }else if(invoke instanceof Date){
                row.createCell(j).setCellValue((Date)invoke);
            }else if(invoke instanceof Long){
                row.createCell(j).setCellValue((Long)invoke);
            } else if(invoke instanceof Integer){
                row.createCell(j).setCellValue((Integer)invoke);
            }else if(invoke instanceof Float){
                row.createCell(j).setCellValue((Float)invoke);
            }
        }else{
            row.createCell(j).setCellValue("");
        }
    }
}

* */

